//
// Created by mgts on 2016/4/11.
//

#ifndef UHYLABTEST_COLOROBTAIN_H
#define UHYLABTEST_COLOROBTAIN_H


#include <android/log.h>

#define  LOG_TAG    "debug-jni"
#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define LOGI(...)  __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)

inline float Min(float a, float b) { return (a < b) ? a : b; }
inline float Max(float a, float b) { return (a > b) ? a : b; }

class MyColor
{
public:
    MyColor() { R = G = B = H = S = V = 0; left = 0, top = 0, right = 0, botton = 0; CX = CY = 0;}
    MyColor(unsigned char R, unsigned char G, unsigned char B) { this->R = R, this->G = G, this->B = B; H = S = V = 0; }

    unsigned char R, G, B;
    float H, S, V;
    unsigned char Y, UR, VB;

    int CX, CY;
    int left, top, right, botton;
};

class ColorObtain {
public:
    void Init(int width, int height);
    void ColorEdit(unsigned char * color, int width, int height, int bit);
    void ColorLoacation(unsigned char * color, int width, int height, int bit);

};
void YUV_RGB(unsigned char y, unsigned char u, unsigned char v, unsigned char &R, unsigned char &G, unsigned char&B);
void RGB_YUV(unsigned char R, unsigned char G, unsigned char B, unsigned char &Y, unsigned char &UR, unsigned char &VB);

void RGB_HSV(unsigned char R, unsigned char G, unsigned char B, float &H, float &S, float &V);
void HSV_RGB(float h, float s, float v, unsigned char & R, unsigned char & G, unsigned char & B);

void PushColorToJava(int width, int height, MyColor * colors, int lenght, bool isTrue, int x, int y, int w, int h);
void PushColorLocation(MyColor * colors);
#endif //UHYLABTEST_COLOROBTAIN_H
